import React, { useEffect, useRef } from 'react';
import * as echarts from 'echarts';
export default function MyEcharts(props) {
  const { option, esHeight, esWidth } = props;
  const containerRef = useRef();
  useEffect(() => {
    console.log('echarts初始化');
    const myChart = echarts.init(containerRef.current);
    myChart.setOption(option);
  });
  return (
    <div
      style={{
        width: esWidth ? esWidth : '600px',
        height: esHeight ? esHeight : '400px',
      }}
      ref={containerRef}
    ></div>
  );
}
